#!/bin/bash

#运行方式 bash deploy.sh ../src/
run_deploy()
{
        #如果该目录下存在deployment.yml
        if [ -f "deployment.yml" ];then
            echo ""
            echo ===================== FOUND ===================
            pwd;
            echo ===============================================
            kubectl apply -f deployment.yml;
        fi

        if [ -f "deployment2.yml" ];then
            echo ""
            echo ===================== FOUND ===================
            pwd;
            echo ===============================================
            kubectl apply -f deployment2.yml;
        fi
}



myfunc()
{
        cd $1;
        run_deploy;
        for x in $(ls .)
        do
                if [ -d "$x" ];then
                        myfunc $x;
                        cd ..
                fi

        done
}

p=.
if [ $1 ];then
    p=$1
fi
echo $p

myfunc $p